//
//  lxCategoryInfoEntity.m
//  luodansc
//
//  Created by 倫 星 on 2012/11/14.
//  Copyright (c) 2012年 方正株式会社. All rights reserved.
//

#import "lxCategoryInfoEntity.h"

@implementation lxCategoryInfoEntity

@synthesize cat_id = _cat_id;
@synthesize name = _name;
@synthesize goodsEntity = _goodsEntity;

- (id)init {
	self = [super init];
	if (self != nil) {
        _cat_id = 0;
        _name = nil;
        _goodsEntity = [[lxGoodsEntity alloc] init];
    }
    return self;
}

- (BOOL)setEntity:(NSDictionary *)dictionary {
    BOOL result = [super setEntity:dictionary];
    if (NO == result) {
        return NO;
    }
    
    _cat_id = [[dictionary objectForKey:@"id"] intValue];
    _name = [lxStringUtility nil2String:[dictionary objectForKey:@"name"]];
    
    NSArray *arrayGoods = [dictionary objectForKey:@"goods"];
    if (nil == arrayGoods) {
        return YES;
    }
    
    int count = [arrayGoods count];
    if (count <= 0) {
        return YES;
    }
    
    NSDictionary *obj = [arrayGoods objectAtIndex:0];
    [_goodsEntity setEntity:obj];
    
    return YES;
}

- (void)dealloc {
    [_goodsEntity release];
    [super dealloc];
}

@end
